package com.sanji.sjmallmodule.account;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.sanji.sjmallapp.BaseActivity;
import com.sanji.sjmallapp.R;
import com.sanji.sjmallconfig.ConfigConts;
import com.sanji.sjmallmanager.activity.ActivityManager;
import com.sanji.sjmallmodule.login.LoginActivity;
import com.sanji.sjmallmodule.login.ResetPasswordActivity;

import butterknife.BindView;
import butterknife.ButterKnife;

/***
 * 账户管理
 **/
public class AccountManagmentActivity extends BaseActivity implements View.OnClickListener {
    @BindView(R.id.common_back_img)
    ImageView commonBackImg;
    @BindView(R.id.common_left_tv)
    TextView commonLeftTv;
    @BindView(R.id.use_account_tv)
    TextView useAccountTv;
    @BindView(R.id.recipt_person_tv)
    TextView reciptPersonTv;
    @BindView(R.id.recipt_address_tv)
    TextView reciptAddressTv;
    @BindView(R.id.recipt_user_phone_tv)
    TextView reciptUserPhoneTv;
    @BindView(R.id.change_pw_tv)
    TextView changePwTv;
    @BindView(R.id.exit_login_btn)
    Button exitLoginBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_account_managment);
        ButterKnife.bind(this);
        initView();
    }

    public void initView() {
        commonLeftTv.setText(getString(R.string.account_management));
        commonBackImg.setOnClickListener(this);
        changePwTv.setOnClickListener(this);
        exitLoginBtn.setOnClickListener(this);

        String account = myShare.getString(ConfigConts.ACCOUNT, getString(R.string.vip_user));
        useAccountTv.setText(account);
        String userName = myShare.getString(ConfigConts.TRUE_NAME,getString(R.string.vip_user));
        reciptPersonTv.setText(userName);
        String reveAddress = myShare.getString(ConfigConts.ADDRESS_STR, "");
        reciptAddressTv.setText(reveAddress);
        String revePhone = myShare.getString(ConfigConts.MOBILE, "");
        reciptUserPhoneTv.setText(revePhone);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.common_back_img:
                finish();
                break;
            case R.id.change_pw_tv:
                //修改密码
                intent = new Intent(this, ResetPasswordActivity.class);
                intent.putExtra("enteType", 1);
                startActivity(intent);
                break;
            case R.id.exit_login_btn:
                //退出登录
                myShare.put(ConfigConts.ACCOUNT, "");
                myShare.put(ConfigConts.USER_PASSWORD, "");
                myShare.put(ConfigConts.IS_REMERBER, false);

                intent = new Intent(this, LoginActivity.class);
                startActivity(intent);
                //销毁栈中的app
                ActivityManager.getInstance().finishAllActivity();
                break;
        }
    }
}
